package com.zhj.rabbitmq.demo.delayqueue;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author zhengjibin
 * @version 1.0.0
 * @ClassName RabbitmqConsumer.java
 * @Description rabbitmq消费者
 * @createTime 2023年03月23日 19:04:00
 */

@Component
public class RabbitmqConsumer {

    //@RabbitListener(queues = {CreateTTLQueueConfig.P_QUEUE_1})
    public void consumerP_Queue1(Message message, Channel channel){
        System.out.println("消费队列"+CreateTTLQueueConfig.P_QUEUE_1+"内容："+message.getBody().toString());
    }

    //@RabbitListener(queues = {CreateTTLQueueConfig.P_QUEUE_2})
    public void consumerP_Queue2(Message message, Channel channel){
        System.out.println("消费队列"+CreateTTLQueueConfig.P_QUEUE_2+"内容："+message.getBody().toString());
    }

    @RabbitListener(queues = {CreateTTLQueueConfig.S_QUEUE})
    public void consumerS_Queue(Message message, Channel channel){
        String str = new String(message.getBody());
        System.out.println("消费死信队列"+CreateTTLQueueConfig.S_QUEUE+"内容："+str);
    }
}
